package com.chenfan.ccp.plug.mybatis.config;

import com.chenfan.ccp.plug.mybatis.mapper.MybatisBaseMapper;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;

/**
 * mybatis的配置中心
 */
public class MybatisConfig extends MapperScannerConfigurer {

    private static ApplicationContext APPLICATION_CONTEXT;

    private static Boolean IS_CAMEL = Boolean.TRUE;


    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        APPLICATION_CONTEXT = applicationContext;
        super.setApplicationContext(applicationContext);

    }

    public static ApplicationContext getApplicationContext(){
        return APPLICATION_CONTEXT;
    }


    public static Boolean getIsCamel(){
        return IS_CAMEL;
    }

    public void setIsCamel(Boolean isCamel) {
        IS_CAMEL = isCamel;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        super.setBasePackage(MybatisBaseMapper.class.getPackage().getName());
        super.afterPropertiesSet();

    }

}
